# https://www.cnblogs.com/zqj-blog/p/10044181.html 【powershell字符串操作】



"Hello, PowerShell" -replace "PowerShell", "www.pstips.net"


"https://172.16.3.3:8443/svn/BDCDJ/trunk/components/kanq-qd-independence"  -replace "(?<=.*/svn/)(\w+)", "$1"


"https://172.16.3.3:8443/svn/BDCDJ/trunk/components/kanq-qd-independence"  -match "(?<=.*/svn/)(?<respo>\w+)(?<relativeSvnPath>.*)$"
Write-Host "LQ----", $Matches.respo
Write-Host "LQ----", $Matches.relativeSvnPath

# =====================================================

function GBKtoUTF8 {
    param ($gbk_text)

    # https://blog.csdn.net/qq_28550263/article/details/121310472 【PowerShell简体中文编码转换】
    [System.Text.Encoding] $GBK = [System.Text.Encoding]::GetEncoding("gb2312");
    $str = $GBK.GetBytes($gbk_text);
    $encodedBytes = [Encoding]::Convert(
        $GBK,
        [Encoding]::UTF8,
        $str
    );
    return [Encoding]::UTF8.GetString($encodedBytes)
}

function  GBKtoUTF8_2_has_problem {
    # GBKtoUTF8 -- 2   好像存在问题.....
    # [System.Text.Encoding]::UTF8.GetString([System.Text.Encoding]::GetEncoding("gb2312").GetBytes("夫礼者"))

}


# =======================================================
<#
    所有的基本操作符形式都大同小异，要处理的数据位于操作符的左右两边，然后通过操作符建立连接。
    #参见oneNote里的 《字符串操作符》 一节
#>

#将文本中指定的字符串替换成目标文本
"Hello Carl,Carl" -replace "Carl", "Eddie"  # Hello Eddie,Eddie

#-ireplace，-creplace，i前缀表示字符串大小写不敏感（insensitive），c前缀表示字符串大小写敏感（case sensitive）。
"Hello Carl,carl" -ireplace "Carl", "Eddie"  #Hello Eddie,Eddie
"Hello Carl,carl" -creplace "Carl", "Eddie" #Hello Eddie,carl

"{0}, {1}" -f 1,2

#
$profileX ="dev"

"Hello {0}" -f  $profileX






$arr = "1,2,3" -split ","
Write-Host $arr 



# 判断是否为空
$empty = "11"
if($empty){
    Write-Host "str is not empty"
}else{
    Write-Host "str is empty"
}
$empty.Length
$empty.Contains()